﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

using DbSharp.Framework.Assertion ;
using DbSharp.Framework.DbObject;
using System.Collections.ObjectModel;


namespace DbSharp.Framework.CaseFile
{
    /// <summary>
    /// Unit Test case class
    /// </summary>
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class UnitTestCase
    {  
        private List<SetupAction> m_ListSetupAction = new List<SetupAction>();
        private List<SetupAction> m_ListTeardownAction = new List<SetupAction>();
        private List<string> m_Tags=new List<string>() ;
        private string m_TagsValue;


        #region Public Methods/Properties
        public ResultsetSection TargetResultsetSection { get;  set; }
        public ResultsetSection ReferResultsetSection { get;  set; }
        public string TestCaseName { get; set; }
        public string TestCaseRemark { get; set; }
        public bool TestInSandbox { get; set; }
        public bool IgnoreThis { get; set; }
        public AssertionType Assertion { get; set; }
        public string TagsValue
        {
            get
            {
                return m_TagsValue;
            }
            set
            {
                m_TagsValue = value;
                m_Tags.Clear() ;
                var tags = m_TagsValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var tag in tags)
                {
                    m_Tags.Add(tag.Trim());
                }
            }
        }
        public List<string> Tags
        {
            get { return m_Tags; }
        }

         

        public void AddSetupStatement(SetupAction action)
        {
            m_ListSetupAction.Add(action);
        }

        public void AddTeardownStatment(SetupAction action)
        {
            m_ListTeardownAction.Add(action);
        }
         

        public ReadOnlyCollection<SetupAction> ListSetupAction
        {
            get { return new ReadOnlyCollection<SetupAction>(m_ListSetupAction); }
        }

        public ReadOnlyCollection<SetupAction> ListTeardownAction
        {
            get { return new ReadOnlyCollection<SetupAction>(m_ListTeardownAction); }
        }


        public override string ToString()
        {
            return TestCaseName;
        }
        #endregion
    }
}
